package com.kundi.dooradmin.service;

import com.kundi.dooradmin.entity.Product;
import com.kundi.dooradmin.mapper.ProductMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Author 赵恒
 * Date 2020/6/22
 */
@Service
public class ProductService {
    @Resource
    ProductMapper productMapper;


    public List<Product> getAll() {
        return productMapper.getAll();
    }

    public Integer insert(Product product) {
        return productMapper.insertSelective(product);
    }

    public Integer update(Product product) {
        return productMapper.updateByPrimaryKeySelective(product);
    }

    public Integer delete(Integer id) {
        return productMapper.deleteById(id);
    }

    public Product getProductByIdWithImage(Integer id) {
        Product p = new Product();
        p.setId(id);
        return productMapper.selectOne(p);
    }
    public Product getProductById(Integer id) {
        return productMapper.getProductById(id);
    }

    public List<Product> getFirstProduct() {
        return productMapper.getFirstProduct();
    }
}
